#ifndef FH_RSA_H_
#define FH_RSA_H_

#include <linux/delay.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/crypto.h>
#include <linux/interrupt.h>

#if 0
#define swab32(x) \
    ((unsigned long)( \
        (((unsigned long)(x) & (unsigned long)0x000000ffUL) << 24) | \
        (((unsigned long)(x) & (unsigned long)0x0000ff00UL) <<  8) | \
        (((unsigned long)(x) & (unsigned long)0x00ff0000UL) >>  8) | \
        (((unsigned long)(x) & (unsigned long)0xff000000UL) >> 24) ))
#endif

#define RSA_CFG 			0x0
#define DMA_REQ_CFG1		0x4
#define RSA_DEBUG			0x8
#define RSA_INT			    0xc
#define RSA_D				0x210
#define RSA_D_X(x)			(RSA_D + ((x) << 3))
#define RSA_N				0x10
#define RSA_N_X(x)			(RSA_N + ((x) << 3))
#define RSA_M				0x410
#define RSA_M_X(x)			(RSA_M + ((x) << 3))
#define RSA_RESULT0			(0x610)
#define RSA_RESULT(x)		(RSA_RESULT0 + ((x) << 2))
#define RSA_BIGDIV_CFG		0x810
#define RSA_ESCAN_CFG0		0x814
#define RSA_ESCAN_CFG1		0x818

#define RSA_MODE			BIT(0)
#define RSA_DMA_EN			BIT(1)
#define RSA_TYPE			BIT(2)
#define RSA_START			BIT(3)
#define RSA_BUS_SEL_OFS		4
#define RSA_M_SIGN			BIT(7)
#define RSA_4096			(1 << 0)
#define RSA_2048			(0 << 0)
#define RSA_ENCRY			(1 << 2)
#define RSA_DECRY			(0 << 2)
#define RSA_M_NEGTIVE		(1 << 7)
#define RSA_M_ACTIVE		(0 << 7)


#define DMA_RX_REQ_SET_SW	BIT(0)
#define DMA_RX_REQ_CLR_SW	BIT(1)


#define INT_EN			    BIT(0)
#define INT_MASK			BIT(1)
#define INT_CLR_SW			BIT(2)
#define INT_SET_SW			BIT(3)
#define INT_STATUS			BIT(4)

#define RSA_MOD_4096		BIT(0)
#define RSA_START			BIT(3)


#define DIVISOR_SHIFT_CNT_CFG_OFS	0
#define DIVISOR_SHIFT_CNT_CFG_MASK	0x0000003f

#define EBIT_LEN_CNT_WORD_4096    0x3f;
#define EBIT_LEN_CNT_WORD_2048    0x1f;
#define BIT_LEN                   0x40;
#define EBIT_LEN                  0x40;


#define EBIT_LEN_CNT_CFG_OFS		0
#define EBIT_LEN_CNT_CFG_MASK		0x0000003f
#define BIT_LEN_OFS					6
#define BIT_LEN_MASK				0x00001fc0
#define EBIT_LEN_OFS				16
#define EBIT_LEN_MASK				0xffff0000

#define WBITS_OFFSET_OFS			0
#define WBIT_OFFSET_MASK			0x0000007f
#define E_SCAN_BIT_CNT_CFG_OFS		16
#define E_SCAN_BIT_CNT_CFG_MASK		0x003f0000


struct fh_rsa_dev {
	/*common driver paras..*/
	void *regs;
	struct device *dev;	/*bind to the platform dev...*/
	struct clk *clk;
	spinlock_t lock;	/*just lock...*/
	u32 irq_no;		/*board info...*/
	struct completion done;
	struct proc_dir_entry *proc_file;
};

#endif /* fh_RSA_H_ */


